﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AutoMapper;
using Portal.Logic.Bootstraper;
using Portal.Model;
using Portal.Repository.Bootstraper;

namespace Portal.Presentation
{
	public class AutomapperConfig
	{
		public static void Configure()
		{
			//Mapper.Initialize(x => GetConfiguration(typeof(RepositoryAutoMapper), Mapper.Configuration));
			//Mapper.Initialize(x => GetConfiguration(typeof(LogicAutoMapper), Mapper.Configuration));
			Mapper.Initialize(x => GetConfiguration(typeof(PresentationAutoMapper), Mapper.Configuration));
		}

		private static void GetConfiguration(Type type, IConfiguration configuration)
		{
			var profiles = type.Assembly.GetTypes().Where(x => typeof(Profile).IsAssignableFrom(x));
			foreach (var profile in profiles)
			{
				configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
			}
		}
	}
}

